//
//  HeadReusableView.m
//  斗鸡TV
//
//  Created by admin on 16/3/11.
//  Copyright © 2016年 admin. All rights reserved.
//

#import "HeadReusableView.h"
#import "ReactiveCocoa.h"
#import "MoreViewController.h"
#import "tabbarController.h"
#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height
@interface HeadReusableView ()

{
    UILabel * headTitleLable;
    WaQuModel * wmd;
}
@end
@implementation HeadReusableView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [[UIColor orangeColor] colorWithAlphaComponent:0.1];
        
        headTitleLable = [[UILabel alloc]initWithFrame:CGRectMake(10, self.frame.size.height-20, self.frame.size.width/2, 20)];
        headTitleLable.font = [UIFont boldSystemFontOfSize:18];
        [self addSubview:headTitleLable];
        
        self.btn = [[UIButton alloc]initWithFrame:CGRectMake(WIDTH-90, self.frame.size.height-20, 80, 20)];
        [[self.btn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
            
            __weak HeadReusableView * weakSelf = self;
            
            NSLog(@"按钮被点击%ld",(long)weakSelf.btn.tag);
            wmd = self.array[self.btn.tag];
            
            MoreViewController * mvc = [MoreViewController new];
            mvc.wuquModel = wmd;

            [[tabbarController getInstance] pushViewController:mvc];
            
            
        }];
//        self.btn.backgroundColor = [UIColor purpleColor];
        [self.btn setTitle:@"更多➡️" forState:UIControlStateNormal];
        [self.btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self addSubview:self.btn];
    }
    
    return  self;
    
}

-(void)setHeadViewTitle:(NSString *)title index:(NSIndexPath *)index
{
    self.btn.tag = index.section;
    headTitleLable.text = title;

}
@end
